package com.tj.admin.rest.financial;


import com.fqgj.common.api.Page;
import com.tj.admin.auth.response.LendingDTO;
import com.tj.admin.auth.response.ReimbursementDTO;
import com.tj.admin.auth.response.StatementDTO;
import com.tj.admin.auth.response.TopUpDTO;
import com.tj.admin.auth.service.FinancialApplication;
import com.tj.admin.auth.vo.*;
import com.tj.bo.common.conf.api.ApiResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/financial")
public class FinancialController {

    @Autowired
    private FinancialApplication financialApplication;

    @RequestMapping(value = "/reimbursement/list")
    public ApiResponse<ReimbursementDTO> reimbursementList(int currentPage, String productName, String startTime, String endTime) {
        List<ReimbursementVo> queryList = financialApplication.queryReimbursementList(currentPage, productName, startTime, endTime);
        ReimbursementDTO dto = new ReimbursementDTO(queryList);
        return new ApiResponse<>(dto).setPage(new Page(queryList.size(), 1, 100));
    }

    @RequestMapping(value = "/lending/list")
    public ApiResponse<LendingDTO> lendingList(int currentPage, String productName, String startTime, String endTime) {
        List<LendingVo> queryList = financialApplication.queryLendingList(currentPage, productName, startTime, endTime);
        LendingDTO dto = new LendingDTO(queryList);
        return new ApiResponse<>(dto).setPage(new Page(queryList.size(), 1, 100));
    }

    @RequestMapping(value = "/statement/list")
    public ApiResponse<StatementDTO> statementList(int currentPage, String startTime, String endTime) {
        Page page = new Page();
        page.setCurrentPage(currentPage);
        page.setPageSize(20);
        ApiResponse<StatementDTO> response = financialApplication.queryStatementList(page, startTime, endTime);
        return response;
    }

    @RequestMapping(value = "/topup/list")
    public ApiResponse<TopUpDTO> topupList(int currentPage, String startTime, String endTime) {
        Page page = new Page();
        page.setCurrentPage(currentPage);
        page.setPageSize(20);
        ApiResponse<TopUpDTO> response = financialApplication.queryTopUpList(page, startTime, endTime);
        return response;
    }


    @RequestMapping(value = "/index")
    public ApiResponse<IndexInfoVo> index() {
        IndexInfoVo indexInfoVo = financialApplication.queryIndex();
        return new ApiResponse<>(indexInfoVo);
    }

}
